/*******************************************OVERVIEW*******************************************************
 
 Political Fear and Loathing on Wall Street
 
 Replication do file
 
 Table 1: Table 1: Electoral Price Risk, 1986-2020
 
 Version July 9 2023 
 
  
********************************************************************************************************************/

clear
set more off
#delimit ;


/*Set Directory -- You will need to adjust this line of code accordingly */; 


cd "/Users/ssaiegh/Files/Mac/VIX/VIX/";

/*Create Log File*/;

log using "Table 1", replace text;


/*Load Data File*/;

use "election_risk.dta";

/*Declare Time Series*/;


tsset case;


/*Estimate Electorally-Induced Jump (Equation 3 in Paper)*/;

gen scale=sqrt(30);

gen dif_vix=vix-F.vix;
gen sigma_sp=sqrt(scale*dif_vix);

gen dif_vix9=vix9d-F.vix9d;
gen sigma_sp_9=sqrt(3*dif_vix9);

gen dif_russell=russell-F.russell;
gen sigma_russell=sqrt(scale*dif_russell);

gen dif_nas=nasdaq-F.nasdaq;
gen sigma_nas=sqrt(scale*dif_nas);

gen dif_djia=djia-F.djia;
gen sigma_dow=sqrt(scale*dif_djia);

gen dif_europe=europe-F.europe;
gen sigma_euro=sqrt(scale*dif_europe);

gen dif_em=em-F.em;
gen sigma_em=sqrt(scale*dif_em);

gen dif_oil=oil-F.oil;
gen sigma_oil=sqrt(scale*dif_oil);

gen dif_gold=gold-F.gold;
gen sigma_gold=sqrt(scale*dif_gold);

/*Generate Table Results*/;

tab year if event==1;
tab year if sigma_sp!=. & event==1;
ttest sigma_sp, by(event);

tab year if event==1 & year<2011;
tab year if sigma_sp!=. & event==1 & year<2011;
ttest sigma_sp if year<2011, by(event);

tab year if event==1 & year>2010;
tab year if sigma_sp!=. & event==1 & year>2010;
ttest sigma_sp if year>2010, by(event);

tab year if event==1 & year>2010;
tab year if sigma_sp_9!=. & event==1 & year>2010;
ttest sigma_sp_9 if year>2010, by(event);

tab year if event==1 & russell!=.;
tab year if sigma_russell!=. & event==1;
ttest sigma_russell, by(event);

tab year if event==1 & djia!=.;
tab year if sigma_dow!=. & event==1;
ttest sigma_dow, by(event);

tab year if event==1 & nasdaq!=.;
tab year if sigma_nas!=. & event==1;
ttest sigma_nas, by(event);

tab year if event==1 & europe!=.;
tab year if sigma_euro!=. & event==1;
ttest sigma_euro, by(event);

tab year if event==1 & em!=.;
tab year if sigma_em!=. & event==1;
ttest sigma_em, by(event);

tab year if event==1 & oil!=.;
tab year if sigma_oil!=. & event==1;
ttest sigma_oil, by(event);

tab year if event==1 & gold!=.;
tab year if sigma_gold!=. & event==1;
ttest sigma_gold, by(event);

tab year if pres==1;
tab year if sigma_sp!=. & pres==1;
ttest sigma_sp, by(pres);


tab year if pres==1 & year<2011;
tab year if sigma_sp!=. & pres==1 & year<2011;
ttest sigma_sp if year<2011, by(pres);

tab year if pres==1 & year>2010;
tab year if sigma_sp!=. & pres==1 & year>2010;
ttest sigma_sp if year>2010, by(pres);

tab year if pres==1 & year>2010;
tab year if sigma_sp_9!=. & pres==1 & year>2010;
ttest sigma_sp_9 if year>2010, by(pres);



log c;
